<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/2
 * Time: 14:08
 */

namespace app\common\controller;


use Wechat\Wxobjopen;

class CardMake extends Wxoption
{

    //初始化积分余额
    public function init_bonus($arr){
//    try {
        //实例化微信
        $options = $this->options($arr['card_id']);
        $WxObj = new Wxobjopen($options);
        $data = [
            'code' => $arr['code'],
            'card_id' => $arr['card_id'],
            'record_bonus' => 0,       //说明
//            'add_bonus' => 0,             //积分变动值  负数为减少
            'custom_field_value2' => $arr['price'].'元',
            'notify_optional' => [
                'is_notify_bonus' => false,
                'is_notify_balance' => false,
                'is_notify_custom_field2' => false,
            ],
        ];
        $res = $WxObj->updateUserInfo($data);
//    } catch (\Exception $e) {
//        $res = ['errcode' => 9999, 'message' => $e->getMessage()];
//    }
        return $res;
    }


}